package yannan.voiplock4ble.adapter;

import android.content.Context;
import android.view.View;

import java.util.List;

import yannan.voiplock4ble.R;
import yannan.voiplock4ble.adapter.base.MyViewHolder;
import yannan.voiplock4ble.adapter.base.RecyclerViewBaseAdapter;
import yannan.voiplock4ble.bean.LockBean;

/**
 * 说明：门锁列表
 * 作者：mainTel
 * 时间：2016/11/23 09:23
 * 备注：
 */
public class LockListAdapter extends RecyclerViewBaseAdapter<LockBean> {

    public LockListAdapter(List<LockBean> list, Context ctx) {
        super(list, ctx);
    }

    @Override
    public int onCreateViewLayoutID(int viewType) {
        return R.layout.item_lock_list;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int poi) {
        LockBean lockBean = list.get(poi);
        holder.setTextView(R.id.tv_lock_serial_num, lockBean.getLockserialId());
        holder.setTextView(R.id.tv_lock_elect, "电量：" + lockBean.getBatteryQuantity() + "%");
        holder.setTextView(R.id.tv_lock_name, lockBean.getLockName());
        holder.get(R.id.tv_del).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnItemClickListener.onItemClick(v, poi);
            }
        });
        holder.get(R.id.tv_edit).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnItemClickListener.onItemClick(v, poi);
            }
        });
        holder.get(R.id.rowFG).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnItemClickListener.onItemClick(v, poi);
            }
        });
    }
}
